bytecomp.el: Warn for `,' not within backquote construct
authorRichard M Stallman <rms@gnu.org>
Sat, 3 Feb 2024 22:47:02 +0000 (17:47 -0500)
committerRichard Stallman <rms@gnu.org>
Sat, 3 Feb 2024 23:12:10 +0000 (18:12 -0500)
(bytecomp--report-comma): New function with `compiler-macro' property.

lisp/emacs-lisp/bytecomp.el

index 6e66771658effeaaeb51a98f460355acc52a753d..5d2aa3355be7feac2881c18933839ea0d486576c 100644 (file)
@@ -5742,6 +5742,16 @@ and corresponding effects."
            (eval form)
          form)))
 
+;; Report comma operator used outside of backquote.
+;; Inside backquote, backquote will transform it before it gets here.
+
+(put '\,  'compiler-macro #'bytecomp--report-comma)
+(defun bytecomp--report-comma (form &rest _ignore)
+  (macroexp-warn-and-return
+   (format-message "`%s' called -- perhaps used not within backquote"
+                   (car form))
+   form (list 'suspicious (car form)) t))
+
 ;; Check for (in)comparable constant values in calls to `eq', `memq' etc.
 
 (defun bytecomp--dodgy-eq-arg-p (x number-ok)